from urllib.request import urlopen

headers = {
    "User_agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0"
}


url = 'https://www.baidu.com'
rest =urlopen(url)
with open('baidu.jpg', mode='wb') as f:
    f.write(rest.read().decode("utf8"))
print("ok")